//Shows error message as ul list
//To write own function for showing validation errors use the next pattern.
//
//IMPORTANT!!!!
// - Write own function "displayErrors"
// - Use array of errors messages as variable              this._messagesText
// - You must to insert id for the error message tag as    this._idError
// - Use this._element as DOM element that is validated    this._element


dojo.provide("dojo.app.myvalidator.errorviews.list");

dojo.declare("dojo.app.myvalidator.errorviews.list", null, {
    _element : null,
    _idError : "",
    _messagesText : [],

    constructor: function(element, idError, messagesText) {
        this._element = element;
        this._idError = idError;
        this._messagesText = messagesText;
    },

    displayErrors: function() {
        var validatedElem = this._element[0];

        var ul = dojo.query(dojo.create('ul', {id : this._idError})).place(validatedElem, "after");
        
        ul.addClass("error");
        dojo.forEach(this._messagesText, function(message) {
            dojo.query(dojo.create('li', {innerHTML : message})).place(ul[0]);
        });
    }
});


